import { defineStore } from "pinia";

// 用户相关 定义 Store
export const useWorkbenchStore = defineStore(
  "workbench",
  () => {
    let controls_list: any = ref("");
    const changeList = (arr: Array<any>) => {
      controls_list.value = arr;
      console.log("controls_list", controls_list);
      return controls_list;
    };
    // 记得 return
    return { controls_list, changeList };
  },
  // TODO: 持久化
  {
    // 配置持久化
    persist: {
      // 调整为兼容多端的API
      storage: {
        setItem(key, value) {
          uni.setStorageSync(key, value);
        },
        getItem(key) {
          return uni.getStorageSync(key);
        },
      },
      paths: ["controls_list"],
    },
  }
);
